package Structural.Proxy.aop.SpringAOP.impl;


import Structural.Proxy.aop.SpringAOP.Result;
import Structural.Proxy.aop.SpringAOP.Log ;
import Structural.Proxy.aop.SpringAOP.TestService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * 需要被拦截的类
 */
public class TestServiceImpl implements TestService
{
/*
 * 日志记录log
 */
public transient Logger log = LoggerFactory.getLogger(getClass());

    @Log(name = "getValue")
    @Override
    public Result getValue(String key)
    {
        Result result = new Result();
        Object obj = new Object();
        if (obj != null)
        {
            result.setSuccess(true);
            result.setMessage("取出成功!");
            result.put("value", obj);
            System.out.println("call redis get success! redis key:" + key + ",value:" + obj);
            log.info("call redis get success! redis key:" + key + ",value:" + obj);
        }
        else
        {
            result.setSuccess(false);
            result.setMessage("取出失败!");
            System.out.println("call redis get failed! redis key:" + key + ",value:" + obj);
            log.error("call redis get failed! redis key:" + key + ",value:" + obj);
        }
        return result;
    }
}
